﻿package org.urbanarmy.utils
{
	/**
	* 	String Utilities class by Ricardo Silva
	*
	*/
	
	public class StringUtils
	{
		public function StringUtils()
		{
			//
		}
		
		/**
		*	Function to check if url format is valid.
		*
		*	@param url The url - Default value: "" (String).
		*
		*	@returns Boolean
		*
		* 	@langversion ActionScript 3.0
		*	@playerversion Flash 9.0
		*/
		public static function validURL(url:String = ""):Boolean
		{
			var pattern:RegExp = /(http:|https:|ftp:)(\/\/)([^ ]+)/gi;
			return url.search(pattern) > -1 ? true : false;
		}
		
		/**
		*	Function to check if email format is valid.
		*
		*	@param email The email - Default value: "" (String).
		*
		*	@returns Boolean
		*
		* 	@langversion ActionScript 3.0
		*	@playerversion Flash 9.0
		*/
		public static function validEmail(email:String = ""):Boolean
		{
			var pattern:RegExp = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/g
			return pattern.test(email)
		}
	}
}